package com.t18;

import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;

/**
 * Created by xuyiwei on 2018/9/11.
 */
public class PreferencesDemo {
    public static void main(String[] args) throws BackingStoreException {
        Preferences preferences = Preferences.userNodeForPackage(PreferencesDemo.class);
        preferences.put("Location","Oz");
        preferences.put("Footwear","Ruby Slippers");
        preferences.putInt("Companions",4);
        preferences.putBoolean("Are there witches",true);
        int usageCount = preferences.getInt("UsageCount",0);
        usageCount++;
        preferences.putInt("UsageCount",usageCount);
        for(String key:preferences.keys()){
            System.out.println(key+" : "+preferences.get(key,null));
        }
        System.out.println("How many companions does DDorothy have ?" + preferences.getInt("Companions",0));
    }
    /**
     * Footwear : Ruby Slippers
     Are there witches : true
     Location : Oz
     Companions : 4
     UsageCount : 1
     How many companions does DDorothy have ?4
     */
}
